<?php
/**
 * Nordic Repository
 * 
 * LICENSE
 * 
 * The new BSD license is applied on this source-file. For further
 * information please visit http://license.nordic-dev.de/newbsd.txt
 * or send an email to andre.moelle@gmail.com.
 */

/**
 * Checks if the source-file is an image.
 * 
 * @category   Nordic
 * @package    Nordic_Upload
 * @copyright  2007 Nordic Development
 * @license    http://license.nordic-dev.de/newbsd.txt (New-BSD license)
 * @author     Andre Moelle <andre.moelle@gmail.com>
 * @version    $Id: Image.php 3 2007-07-08 09:21:42Z andre.moelle $
 */
class Nordic_Upload_Filter_Image extends Nordic_Upload_Filter_Sample
{
	/**
	 * Available image-types.
	 * 
	 * @var Array
	 */
	private $_types = array(
		IMAGETYPE_GIF => 'gif',
		IMAGETYPE_JPEG => 'jpeg',
		IMAGETYPE_PNG => 'png',
		IMAGETYPE_SWF => 'swf',
		IMAGETYPE_PSD => 'psd',
		IMAGETYPE_BMP => 'bmp',
		IMAGETYPE_TIFF_II => 'tiff',
		IMAGETYPE_TIFF_MM => 'tiff',
		IMAGETYPE_JPC => 'jpc',
		IMAGETYPE_JP2 => 'jp2',
		IMAGETYPE_JPX => 'jpx',
		IMAGETYPE_JB2 => 'jb2',
		IMAGETYPE_SWC => 'swc',
		IMAGETYPE_IFF => 'iff',
		IMAGETYPE_WBMP => 'wbmp',
		IMAGETYPE_XBM => 'xbm'
	);
	
	/**
	 * @see Nordic_Upload_Filter_Interface::getExtension()
	 */
	public function getExtension ()
	{
		return $this->_types[exif_imagetype($this->_source)];
	}
	
	/**
	 * @see Nordic_Upload_Filter_Interface::process()
	 */
	public function process ()
	{
		return (bool)exif_imagetype($this->_source);
	}
}
?>